package com.hutao.medical.controller.print;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hutao.medical.common.util.Result;
import com.hutao.medical.pojo.RegisterdMail;
import com.hutao.medical.pojo.vo.MailPrintVo;
import com.hutao.medical.service.print.RegisterMailService;

/**
 * 病案邮寄
 * @author yeyongli
 *
 */
@RequestMapping("/mail")
@Controller
public class RegisterdMailController {
	private static final Logger log = LoggerFactory.getLogger(RegisterdMailController.class);
	
	@Autowired
	private RegisterMailService registerMailService;
	
	@PostMapping("/insertRegisterMail")
	@ResponseBody
	public Result insertRegisterMail(RegisterdMail registerMail) {
		Result result = registerMailService.insertRegisterMail(registerMail);
		return result;
	}
	
	
	@RequestMapping("/mailMedPrintDetail")
	public String mailMedPrintDetail(){
		return "mailprint/mailMedPrintDetail";
	}
	
	
	@ResponseBody
	@RequestMapping("/selectMailRecordByCondition")
	public Result selectPrintRecordByCondition(MailPrintVo mailPrintVo) {
		try {
			Map<String, Object> map = registerMailService.getRegisterMailPage(mailPrintVo);
			return new Result(true, "查询成功!", map);
		} catch (Exception e) {
			log.error("邮寄分页查询异常----" + e.getMessage());
			return new Result(false, "系统异常!", null, 500);
		}
	}
	
	@ResponseBody
	@RequestMapping("/deleteById")
	public Result deleteById(Integer id) {
		try {
			registerMailService.deleteById(id);
			return new Result(true, "删除成功!");
		} catch (Exception e) {
			log.error("删除邮件记录异常异常---- id=" + id + e.getMessage());
			return new Result(false, "系统异常!", null, 500);
		}
	}
	
	@ResponseBody
	@RequestMapping("/updatePrintStatusById")
	public Result updatePrintStatusById(Integer id, Integer printStatus) {
		try {
			registerMailService.updatePrintStatusById(id, printStatus);
			return new Result(true, "修改成功!");
		} catch (Exception e) {
			log.error("修改邮件记录异常异常---- id=" + id + e.getMessage());
			return new Result(false, "系统异常!", null, 500);
		}
	}
	
	
	
	
	
	

}
